/**
* Store 数据提交模块
* @author LoneWolf
*/
import storage from '@/utils/storage'

export default {
    saveUserInfo (state, userInfo) {
        state.userInfo = userInfo
        storage.setItem('userInfo', userInfo)
    },
    menuToggle (state) {
        state.isCollapse = !state.isCollapse
    },
    addTag (state, obj) {
        if (state.tagList.findIndex(item => obj.path === item.path) !== -1) return
        state.tagList.push(obj)
    },
    removeTag (state, path) {
        const index = state.tagList.findIndex(item => item.path === path)
        if (index === -1) return
        state.tagList.splice(index)
    },
    themeToggle (state, isDark) {
        state.theme = isDark ? 'dark' : 'light'
    }
}